#include <stdio.h>
#include <string.h>
#define MAXLEN 1001
void nextnum(char t[], int next[]) 
{
    int j = 0, k = -1;
    next[0] = -1;
    int len = strlen(t);
    while (j < len - 1) 
	{
        if (k == -1 || t[j] == t[k]) 
		{
            j++;
            k++;
            next[j] = k;
        } 
		else 
		{
            k = next[k];
        }
    }
}

int main() 
{
    char t[MAXLEN];
    int next[MAXLEN];
    scanf("%s", t);
    nextnum(t, next);
    int len = strlen(t);
    for (int i = 0; i < len; i++) 
	{
        if (i > 0) 
		{
            printf(" ");
        }
        printf("%d", next[i] + 1);
    }
    printf("\n");
    return 0;
}
